package com.basic;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DataTest {



    public static void main(String[] args) {

        //获取日期 年月 格式的时间 例 202001
        //时间格式化
//        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM");
//        String dateString = formatter.format(new Date());
//        System.out.println("riqi="+dateString);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(new Date());
        System.out.println("----today-----"+dateString);
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.HOUR,-2);
        String startTime = new SimpleDateFormat("yyyy-MM-dd hh:00:00").format(calendar.getTime());
        if(startTime.contains(dateString)){
            System.out.println("----时间为今天-----："+startTime.contains(dateString));
        }
        System.out.println("----start-----"+startTime);
        Calendar calendar2 = Calendar.getInstance();
        calendar2.add(Calendar.HOUR,0);
        String endTime = new SimpleDateFormat("yyyy-MM-dd HH:00:00").format(calendar2.getTime());
        System.out.println("----end-----"+endTime);


    }
}
